﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Model
{
    /// <summary>
    /// 账户信息
    /// </summary>
    public class Account
    {
        private string username;
        private string chanel;
        private string serverID;
        private Characters character;
        private string password;
        private string secureCode;

        /// <summary>
        /// 用户名
        /// </summary>
        public string Username
        {
            get { return username; }
            set { username = value; }
        }

        /// <summary>
        /// 密码
        /// </summary>
        public string Password
        {
            get { return password; }
            set { password = value; }
        }

        /// <summary>
        /// 安全密码(仓库，移动需要输入的密码)
        /// </summary>
        public string SecureCode
        {
            get { return secureCode; }
            set { secureCode = value; }
        }

        /// <summary>
        /// 账户拥有的角色
        /// </summary>
        public Characters Character
        {
            get { return character; }
            set { character = value; }
        }

        /// <summary>
        /// 所在平台
        /// </summary>
        public string Chanel
        {
            get { return chanel; }
            set { chanel = value; }
        }

        /// <summary>
        /// 服务器编号
        /// </summary>
        public string ServerID
        {
            get { return serverID; }
            set { serverID = value; }
        }

        public override string ToString()
        {
            return this.chanel + " " + this.serverID + " " + this.character.Name;
        }

        public string ToString(string sp)
        {
            return this.chanel + sp + this.serverID + sp + this.character.Name;
        }

        public override bool Equals(object obj)
        {
            Account account = obj as Account;
            if (account!=null)
            {
                //如果平台相同，服务器相同，角色名相同，则认为两个账户相等
                if (account.Chanel == this.chanel &&account.ServerID==this.serverID&&account.Character.Name==this.character.Name)
                {
                    return true;
                }
            }
            return false;
        }

        //用于key
        public override int GetHashCode()
        {
            return (this.chanel + this.serverID + this.character.Name).GetHashCode();
        }
    }
    
    /// <summary>
    /// 平台
    /// </summary>
    public enum Chanels
    {
        Chanel6711,
        ChanelBaidu,
        Chanel51wan,
        Chanel37wan,
        ChanelGame2,
        ChanelVeryCD
    }
}
